//The headers
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>
#include <windows.h>
#include "sdlstart.h"
#include "world.h"

using namespace std;

int main( int argc, char* args[] )
{

    //Make sure the program waits for a quit
    bool quit = false;

    sdlstart gamestart;

    //Initialize
    if( gamestart.init() == false )
    {
        return 1;
    }
    //Load the files
    if( gamestart.load_files() == false )
    {
        return 1;
    }

    int enemyanim = 0;

    //While the user hasn't quit
    while( quit == false )
    {

        //Apply the surface to the screen
        gamestart.apply_surface( 0, 0, gamestart.background, gamestart.screen );

        //Apply the second surface to the screen
        gamestart.apply_surface( 250, 280, gamestart.char1, gamestart.screen );

        //Apply the second surface to the screen
        gamestart.apply_surface( 140, 320, gamestart.char2, gamestart.screen );

        //Apply the second surface to the screen
        gamestart.apply_surface( 30, 280, gamestart.char3, gamestart.screen );

        if ( enemyanim == 0)
        {
            //Apply the third surface to the screen
            gamestart.apply_surface( 420, 120, gamestart.enemy, gamestart.screen );

            enemyanim = 1;
        }

        else
        {
            //Apply the third surface to the screen
            gamestart.apply_surface( 420, 120, gamestart.enemy2, gamestart.screen );

            enemyanim = 0;
        }

        //Apply the hud surface to the screen
        gamestart.apply_surface( 0, 460, gamestart.hud, gamestart.screen );

        //Apply the last surface to the screen
        gamestart.apply_surface( 0, 0, gamestart.header, gamestart.screen );

        //Update the screen
        if( SDL_Flip( gamestart.screen ) == -1 )
        {
            return 1;
        }

        Sleep(500);

        //While there's an event to handle
        while( SDL_PollEvent( &gamestart.event ) )
        {
            //If the user has Xed out the window
            if( gamestart.event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }
    }

    //Free the surface and quit
    gamestart.clean_up();

    return 0;
}

